package top.shen33.yang.controller;

import org.springframework.web.multipart.MultipartFile;
import top.shen33.yang.base.R;
import top.shen33.yang.model.entity.RbacRole;
import top.shen33.yang.services.RbacRoleService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author oreilly
 * @since 2018-08-23
 */
@RestController
@RequestMapping("/rbacRole")
    public class RbacRoleController extends BaseController<RbacRole> {


            @Autowired
            private RbacRoleService rbacRoleService;




            @Override
            public Object doAdd(@RequestBody RbacRole rbacRole) throws Exception {

                    rbacRoleService.doAdd(rbacRole);
                    return R.ok(rbacRole);
            }

            @Override
            public Object deDelete(String[] ids) throws Exception {

                    rbacRoleService.doDelete(ids);
                    return R.ok("delete ok");
            }

            @Override
            public Object doUpdate(@RequestBody RbacRole rbacRole) throws Exception {

                    rbacRoleService.doUpdate(rbacRole);
                    return R.ok(rbacRole);
            }

            @Override
            public Object getOne(@PathVariable String id) throws Exception {
                    RbacRole rbacRole = rbacRoleService.getOne(id);
                    return R.ok(rbacRole);
            }

//            @RequestMapping("/detail/{sid}")
//            public Object detail(@PathVariable String sid) throws Exception {
//                    RbacRole rbacRole = rbacRoleService.detail(sid);
//                    return R.ok(rbacRole);
//            }


            public Object all(RbacRole rbacRole) throws Exception{
                    List<RbacRole> rbacRoleList = rbacRoleService.all(rbacRole);
                    return R.ok(rbacRoleList);
            }

        @Override
        public void exportExcel(HttpServletResponse response, RbacRole rbacRole) throws Exception {

        }

        @Override
        public Object importExcel(MultipartFile file) throws Exception {
                return null;
        }

        @Override
            public Object pageInfo(Page page, RbacRole rbacRole) throws Exception {

                    Page<RbacRole> rbacRolePage = rbacRoleService.pageInfo(page, rbacRole);
                    return R.ok("page",rbacRolePage);
            }



        }

